function createExportForm(){
	remove_element_by_id('exportDiv');
	var exportD = document.createElement('DIV');
	exportD.id='exportDiv';
	document.body.appendChild(exportD);
	setPosition(exportD,580,100);

	var submitAnalysis = document.createElement('INPUT');
	submitAnalysis.type='button';
	submitAnalysis.id='exportAnalysis';
	submitAnalysis.value='Export Analysis';
	submitAnalysis.onclick=exportedPage;
	exportD.appendChild(submitAnalysis);

	return false;
}

function exportedPage(){
	var url = location.protocol+'//'+location.host+ location.pathname +
	'#?variavel1==='+ CNVtargetNodes() +'&&&variavel2==='+ 
	document.getElementById('choose_sample').innerHTML;
	url = 	url.replace(/"/g, "'");
	var  htm = window.open('', '', 'menubar=yes,scrollbars=yes,resizable=yes');
	htm.document.body.innerHTML = '<p id="programTitle" style="position: absolute; left: 50px; top: 20px; '+
		'font-family: arial,sans-serif; font-size: 24px; font-style: italic;">CNViewer</p>'+
		'<a id="recoverButton" href="' + url + '"; style="position: absolute; left: 20px; top: 190px;"'+
		'>Recover Analysis</a>';
		
	var similarity = document.getElementById('CNV').similarity;

	if (similarity.metric != undefined) {
		var metric = createParagraph('analysisMetric', 'METRIC:\t' + similarity.metric[0], htm.document.body);
		setPosition(metric, 20, 100);
		setFont(metric, "14px");
		
		var target = createParagraph('analysisTarget', 'TARGET SAMPLE:\t' + similarity.sample[0],htm.document.body);
		setPosition(target, 20, 130);
		setFont(target, "14px");
		
		var chromosomeString = '';
		var label = 'CHROMOSOME';
		var chTotal = similarity.chromosome.length;
		if (chTotal > 1) {
			label = label + 'S';
		}
		for (var i = 0; i < chTotal; i = i + 1) {
			if (i == (chTotal - 1)) {
				chromosomeString = chromosomeString + similarity.chromosome[i];
			}
			else {
				chromosomeString = chromosomeString + similarity.chromosome[i] + ', ';
			}
		}
		chromosome = createParagraph('analysisChromosome', label + ':\t' + chromosomeString, htm.document.body);
		setPosition(chromosome, 20, 160);
		setFont(chromosome, "14px");
	}

	var analysisTitle = createParagraph('analysisTitle', document.getElementById('chartTitle').value, htm.document.body);
	setPosition(analysisTitle, 35, 75);
	setFont(analysisTitle, "14px", 'italic','', 'bold');

	var date = createParagraph('analysisDate', Date(),htm.document.body);
	setPosition(date, 200, 200);
	setFont(date, "12px");
	
	return false;
}

function CNVtargetNodes(){

	var cnv = document.getElementById('CNV');
	var retrieveData = new Object;
	retrieveData.segData = cnv.segData;
	retrieveData.xAxis = cnv.xAxis;
	retrieveData.ch = cnv.ch;
	retrieveData.chRegions = cnv.chRegions;
	retrieveData.extractedSegData = cnv.extractedSegData;
	retrieveData.sampleIndex = cnv.sampleIndex;
	retrieveData.mapAnswer = cnv.mapAnswer;
	retrieveData.index = cnv.index;
	retrieveData.max = cnv.max;
	retrieveData.min = cnv.min;
	retrieveData.realSize = cnv.realSize;
	retrieveData.ready = cnv.ready;
	retrieveData.similarity = cnv.similarity;
	retrieveData.legends = cnv.legends;	
	retrieveData.clinical = cnv.clinical;
	retrieveData.analysisTitle = cnv.analysisTitle;

	return JSON.stringify(retrieveData);
}